<?php
use  Illuminate\Support\Facades\DB;

function response_json($status = 0, $message = '', $data = []){
    $return = [
        'status' => $status,
        'message' => $message,
        'data' => $data
    ];
    echo json_encode($return);exit;
}

function getFile($id)
{
    $ids = explode(',', trim($id, ','));
    $data = Db::table('files')->select(['id', 'real_name', 'url', 'user_id'])
        ->whereIn('id', $ids)
        ->get();
    foreach ($data as &$row) {
        $row->name = $row->real_name;
    }
    return $data ? $data : [];
}

function getPics($pics)
{
    $result = '';
    foreach ($pics as $row) {
        $result .= $row['id'] . ',';
    }
    return rtrim($result, ',');
}